﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>@ViewBag.Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content=""> 
    <link rel="shortcut icon" href="~/Content/images/favicon.ico")" />
    <link href="@Url.Content("~/Content/css/bootstrap.min.css")" rel="stylesheet">
    <script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/js/UserLocation.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/js/Layout.js")" type="text/javascript"></script>
<!-- Custom styles for this template -->
	<link href="@Url.Content("~/Content/css/preview.css")" rel="stylesheet">
    <link href="@Url.Content("~/Content/css/mystyle.css")" rel="stylesheet">
</head>
<body class="eternity-form " >
    <div class="navbar navbar-fixed-top navbar-inverse " role="navigation">
      <div class="container"  >
        <div class="navbar-header">
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="@Url.Action("Index", "NepaliCorner")">NepaliCorner</a>
        </div>
        <div class="collapse navbar-collapse">
          <ul class="nav navbar-nav">
              @*<li><a href="#about">About</a></li>*@
              @*              Create post not enable for now*@
              <li>  <div id="userLocation"> </div></li>
            <li>@Html.ActionLink("Create Post", "CreatePost", "Post")</li>
            <li>@Html.ActionLink("Contact Us", "ContactUs", "NepaliCorner")</li>
          </ul>
@*Login and signup not enabled for now*@
@*        <ul class="nav navbar-nav pull-right"  id="NCResult">                
            @if (Session["Username"] != null)
                {
                    string userd = Convert.ToString(Session["Email"]);
                    <div class="dropdown">
                      <a id="dLabel" role="button" class="welcomeuser" data-toggle="dropdown" data-target="#" href="/page.html">
                        @userd<span class="caret"></span>
                      </a>
                      <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
                       <li>@Html.ActionLink("Sign Out", "Logout", "LogIn")</li>
                      </ul>
                    </div>
                }
                else
                {                          
                    <li >@Html.ActionLink("LOGIN", "GetLogInPage", "LogIn")</li>
                    <li>@Html.ActionLink("SIGNUP", "RegisterAccount", "Account")</li>
                }
        </ul>  *@ 
        </div><!-- /.nav-collapse -->
         
      </div><!-- /.container -->
    </div><!-- /.navbar -->

    <div class="container">
      <div class="row row-offcanvas row-offcanvas-right">
  
        <div class="col-xs-12 col-sm-9">
          
		   <div class="visible-xs" style="position:fixed; top:50px; z-index:999; right:0;">
          
		<p class="pull-right visible-xs">
		
            <button type="button" class="btn btn-primary btn" data-toggle="offcanvas">
			<span class="glyphicon glyphicon-chevron-left"></span>
				View Categories</button>
          </p>
		  </div>
          <div class="" style="margin-top:15px;">
              <div class="row well">
                  @*@Html.MvcSiteMap().Menu(false, true, true)
                  <p>Start of Breadcrumbs:</p>*@
                  @Html.MvcSiteMap().SiteMapPath()
                  <br/> <br />
                  @RenderBody()
              </div>
          </div><!--/row-->
        </div><!--/span-->
        <div class="col-xs-6 col-sm-3 sidebar-offcanvas" id="sidebar" role="navigation">	
           @RenderSection("RightSideBar", required: false)	  
               <div class=" registration-left-section" >
                <div class="subcribe-content">
                <iframe src="//www.facebook.com/plugins/likebox.php?href=https%3A%2F%2Fwww.facebook.com%2FNepaliCorner&amp;width&amp;
                height=290&amp;colorscheme=light&amp;show_faces=true&amp;header=true&amp;stream=false&amp;show_border=true&amp;appId=739935299370873" 
                scrolling="no" frameborder="0" style="border:none; overflow:hidden; height:290px; width:235px; margin:12px;"  allowTransparency="true"></iframe>                            
                </div>
        </div><!--/span-->
      </div><!--/row-->            
           @RenderSection("registerUserDetails", required: false) 
          <hr />
    </div>
    <footer>
        <p>&copy; NepaliCorner 2014</p>
    </footer>
    </div>

    <script type="text/javascript" src="@Url.Content("~/Scripts/jquery.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/js/bootstrap.min.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/jquery-ui.min.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/js/respond.src.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/js/jquery.icheck.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/js/placeholders.min.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/js/waypoints.min.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/js/jquery.panelSnap.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/js/modernizr.js")" ></script><script type="text/javascript"></script>
        <script type="text/javascript"> $(function () {



     //function GetStateName() {
     function displayLocation(latitude, longitude) {
         var request = new XMLHttpRequest();

         var method = 'GET';
         var url = 'http://maps.googleapis.com/maps/api/geocode/json?latlng=' + latitude + ',' + longitude + '&sensor=true';
         var async = true;

         request.open(method, url, async);
         request.onreadystatechange = function () {
             if (request.readyState == 4 && request.status == 200) {
                 var data = JSON.parse(request.responseText);
                 var address = data.results[0];
                 $('#userLocation').text(
                     );// city



                 $.ajax({
                     url: "post/ViewNeededPosts?stateName=" + address.address_components[5].long_name,
                     type: 'GET',
                     cache: false,
                     success: function (result) {
                         $('#neededposts').html(result);
                     }
                 });
                 $.ajax({
                     url: "post/ViewAvailablePosts?stateName=" + address.address_components[5].long_name,
                     type: 'GET',
                     cache: false,
                     success: function (result) {
                         $('#availableposts').html(result);
                     }
                 });





                 //  address.address_components[6].long_name +  //state 
                 //  address.address_components[7].long_name ); //country
                 //return address.address_components[5].long_name;
                 //document.write(address.address_components[5].long_name);
             }
         };
         request.send();
     };

     var successCallback = function (position) {
         var x = position.coords.latitude;
         var y = position.coords.longitude;
         displayLocation(x, y);
     };

     var errorCallback = function (error) {
         var errorMessage = 'Unknown error';
         switch (error.code) {
             case 1:
                 errorMessage = 'Permission denied';
                 break;
             case 2:
                 errorMessage = 'Position unavailable';
                 break;
             case 3:
                 errorMessage = 'Timeout';
                 break;
         }
         document.write(errorMessage);
     };

     var options = {
         enableHighAccuracy: true,
         timeout: 1000,
         maximumAge: 0
     };

     navigator.geolocation.getCurrentPosition(successCallback, errorCallback, options);
























               // $("#userLocation").text = "test1";
                $.ajax({
                    url: "post/ViewNeededPosts?stateName=" + address.address_components[3].long_name,
                    type: 'GET',
                    cache: false,
                    success: function (result) {
                        $('#neededposts').html(result);
                    }
                });
                $.ajax({
                    url: "post/ViewAvailablePosts?stateName=" + address.address_components[3].long_name,
                    type: 'GET',
                    cache: false,
                    success: function (result) {
                        $('#availableposts').html(result);
                    }
                });
                return false;
            });
        </script>
  </body>
</html>